package com.yuwei.device


import android.util.Log
import androidx.recyclerview.widget.LinearLayoutManager
import com.alibaba.android.arouter.facade.annotation.Route
import com.yuwei.base.BaseActivity
import com.yuwei.base.path.RouterPath
import com.yuwei.device.adapter.DeviceAdapter
import com.yuwei.device.databinding.ActivityDeviceBinding
import com.yuwei.device.viewmodel.DeviceViewModel
import dagger.hilt.android.AndroidEntryPoint

@AndroidEntryPoint
@Route(path = RouterPath.MODULE_DEVICE_ACTIVITY)
class DeviceActivity : BaseActivity<ActivityDeviceBinding,DeviceViewModel>() {
    val deviceAdapter = DeviceAdapter()
    override fun initView() {
        vm.getDevice()
        binding.deviceRv.adapter = deviceAdapter
        binding.deviceRv.layoutManager = LinearLayoutManager(this)
        binding.patrolBack.setOnClickListener {
            finish()
        }
    }

    override fun initData() {
        vm.getDeviceSuccess.observe(this){
            Log.e("TAG", "initData: device"+it[0].deviceType)
            deviceAdapter.data.addAll(it)
            deviceAdapter.notifyDataSetChanged()
        }
    }

}